const cookie = {
  remove(key) {
    const expires = new Date();
    expires.setTime(expires.getTime() - 1);
    document.cookie = `${key}=;expires=${expires.toGMTString()};path=/`;
  },

  get(key) {
    const pattern = new RegExp(`${key}=([^=;]+)`);
    return document.cookie.match(pattern) ? RegExp.$1 : '';
  },

  set(key, value, expireDays = 3650) {
    const expires = new Date();
    expires.setTime(expires.getTime() + expireDays * 24 * 60 * 60 * 1000);
    document.cookie = `${key}=${escape(value)};expires=${expires.toGMTString()};path=/`;
  },
};

export {
  cookie,
};
